/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Estacionamento.DAOEspecifico;

import Estacionamento.ClassesBasicas.Cliente;
import Estacionamento.ClassesBasicas.Plano;
import Estacionamento.DAOGenerico.DAOGenerico;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;

/**
 *
 * @author Italo Valença
 */
public class DAOPlano extends DAOGenerico<Plano> implements IDAOPlano {

}
/*
 EntityManagerFactory emf;
 EntityManager em;

 public DAOPlano() {
 emf = Persistence.createEntityManagerFactory("estacionamento");
 em = emf.createEntityManager();
 }

 @Override
 public void ExcluirPlano(Plano plano) throws Exception {
 try {
 em.getTransaction().begin();
 em.remove(em.getReference(Plano.class, plano.getId()));
 em.getTransaction().commit();
 emf.close();
 } catch (Exception ex) {
 throw new Exception(ex.getMessage());

 }
 }

 @Override
 public Plano ListarPlano(String tipo) throws Exception {

 try {
 em.getTransaction().begin();
 Query consulta = em.createQuery("select plano from Plano plano where = plano.tipoPlano = tipo");
 Plano plano = (Plano) consulta;
 em.getTransaction().commit();
 emf.close();
 return plano;

 } catch (Exception ex) {
 throw new Exception(ex.getMessage());
 }
 }
 @Override
 public List<Plano> ListarTodosPlanos() throws Exception{
 try {
 em.getTransaction().begin();
 Query consulta = em.createQuery("select plano from Plano plano");
 List<Plano> plano = consulta.getResultList();
 em.getTransaction().commit();
 emf.close();
 return plano;

 } catch (Exception ex) {
 throw new Exception(ex.getMessage());
 }
 }
 /*
 @Override
 public List<Plano> ListarPlanoPorCliente(Cliente cli) throws Exception {

 try {
 em.getTransaction().begin();
 Query consulta = em.createQuery("select * from Plano plano where cliente.cpf = '" + cli.getCpf() + "'");
 List<Plano> plano = consulta.getResultList();
 em.getTransaction().commit();
 emf.close();
 return plano;

 } catch (Exception ex) {
 throw new Exception(ex.getMessage());
 }
 }*/

